package com.brackets;

import com.brackets.stringparser.StringLayout;
import com.brackets.stringparser.StringParser;

/**
 * @author Dmitry
 */
public class ParserContext {

    private StringParser parser;
    private StringLayout layout;

    public StringParser getParser() {
        return parser;
    }

    public void setParser(StringParser parser) {
        this.parser = parser;
    }

    public StringLayout getLayout() {
        return layout;
    }

    public void setLayout(StringLayout layout) {
        this.layout = layout;
    }
    
    public String positionString(int index){
        int lineNumber=layout.getLineNumber(index);
        int offset=layout.getOffsetInLine(index);
        if(lineNumber==0){
            return "offset "+offset;
        }
        return "line "+lineNumber+" offset "+offset;
    }
}
